﻿<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:z='#RowsetSchema' xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:asp="remove">

	<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="yes"/>
  
	<xsl:template match="/">
		<xsl:choose>
      <xsl:when test="/SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault/faultstring">
        <xsl:value-of select="/SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault/faultstring" />
      </xsl:when>
			<xsl:when test="/xml/rs:data/z:row">
				<table cellpadding="3">
					<tr>
            <th>
              Description
            </th>
						<th>
							Reason
						</th>
						<th>
							Status
						</th>
						<th>
							Current Task
						</th>
						<th>
							Modified By
						</th>
						<th>
							Modified
						</th>
					</tr>
					<xsl:apply-templates/>
				</table>
			</xsl:when>
			<xsl:otherwise>
				Tasks not found
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="z:row">
		<tr>
      <td>
        <xsl:value-of select="@ows__x007b_f97ead54_x002d_7466_x002d_4351_x002d_a28f_x002d_cb2a552686c1_x007d_" />
      </td>
			<td>
				<xsl:value-of select="@ows__x007b_6ad74138_x002d_e53b_x002d_41c9_x002d_aa61_x002d_685206440f06_x007d_" />
			</td>
			<td>
				<xsl:choose>
					<xsl:when test="@ows_ChangeRe='0'">
						Not Started
					</xsl:when>
					<xsl:when test="@ows_ChangeRe='1'">
						Failed On Start
					</xsl:when>
					<xsl:when test="@ows_ChangeRe='2'">
						In Progress
					</xsl:when>
					<xsl:when test="@ows_ChangeRe='3'">
						Error Occurred
					</xsl:when>
					<xsl:when test="@ows_ChangeRe='4'">
						Stopped By User
					</xsl:when>
					<xsl:when test="@ows_ChangeRe='5'">
						Completed
					</xsl:when>
					<xsl:when test="@ows_ChangeRe='6'">
						Failed On Start Retrying
					</xsl:when>
					<xsl:when test="@ows_ChangeRe='7'">
						Error Occurred Retrying
					</xsl:when>
					<xsl:when test="@ows_ChangeRe='8'">
						View Query Overflow
					</xsl:when>
					<xsl:otherwise>
						Unknown
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td>
				<xsl:value-of select="@ows_Current_x0020_Task" />
			</td>
			<td>
				<xsl:value-of select="@ows_Modified_x0020_By" />
			</td>
			<td>
				<xsl:value-of select="@ows_Modified" />
			</td>
		</tr>
	</xsl:template>

</xsl:stylesheet>